{{- if .Values.clusterScoped -}}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ include "single-redis-operator.serviceAccountName" . }}
subjects:
- kind: ServiceAccount
  name: {{ include "single-redis-operator.serviceAccountName" . }}
  {{ if .Values.watchNamespace }}
  namespace: "{{ .Values.watchNamespace }}"
  {{ else }}
  namespace: "{{ .Release.Namespace }}"
  {{ end }}
roleRef:
  kind: ClusterRole
  name: {{ include "single-redis-operator.serviceAccountName" . }}
  apiGroup: rbac.authorization.k8s.io
{{- end }}